package com.zzsz.service.impl;

import com.zzsz.domain.EmailLog;
import com.zzsz.mapper.EmailLogMapper;
import com.zzsz.service.EmailLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * --- 这有何难 --- 
 * ƪ(˘⌣˘)ʃ
 *
 * @author 超级无敌张恒阳大王
 * @date 5/9/2025
 * @desc 邮件日志serviceImpl
 */
@Slf4j
@Service
public class EmailLogServiceImpl implements EmailLogService {

    @Autowired
    private EmailLogMapper emailLogMapper;

    @Override
    public PageInfo<EmailLog> getEmailLogList(Map<String, Object> params) {
        Integer pageNum = (Integer) params.getOrDefault("pageNum", 1);
        Integer pageSize = (Integer) params.getOrDefault("pageSize", 10);
        
        PageHelper.startPage(pageNum, pageSize);
        List<EmailLog> emailLogList = emailLogMapper.selectList(params);
        log.debug("ServiceImpl层 emailLogList: {}", emailLogList);
        return new PageInfo<>(emailLogList);
    }

    @Override
    public EmailLog getEmailLogDetail(Long id) {
        log.info("获取邮件日志详情，ID: {}", id);
        return emailLogMapper.selectById(id);
    }

    @Override
    public int deleteEmailLogs(Long[] ids) {
        log.info("批量删除邮件日志，IDs: {}", ids);
        return emailLogMapper.deleteByIds(ids);
    }

    @Override
    public List<EmailLog> exportEmailLogs(Map<String, Object> params) {
        log.info("导出邮件日志列表，参数: {}", params);
        return emailLogMapper.exportList(params);
    }
}